home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / sbhc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-04  |  2.9 KB  |  86 lines

  1. /* Copyright (C) 1994 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* sbhc.h */
  20. /* BoundedHuffman filter state definition */
  21. /* Requires strimpl.h */
  22. #include "shc.h"
  23.  
  24. /*
  25.  * The BoundedHuffman filters extend the basic Huffman coding model by
  26.  * providing the ability to encode runs of zeros as a single data item,
  27.  * and by providing an end-of-data (EOD) marker.
  28.  */
  29. #define max_zero_run 100
  30.  
  31. /* Common state */
  32. #define stream_BHC_state_common\
  33.     stream_hc_state_common;\
  34.     hc_definition definition;\
  35.         /* The client sets the following before initialization. */\
  36.     bool EndOfData;\
  37.     uint EncodeZeroRuns;\
  38.         /* The following are updated dynamically. */\
  39.     int zeros        /* # of zeros scanned or left to output */
  40. typedef struct stream_BHC_state_s {
  41.     stream_BHC_state_common;
  42. } stream_BHC_state;
  43.  
  44. /* BoundedHuffmanEncode */
  45. typedef struct stream_BHCE_state_s {
  46.     stream_BHC_state_common;
  47.     hce_table encode;
  48. } stream_BHCE_state;
  49. #define private_st_BHCE_state()    /* in sbhc.c */\
  50.   gs_private_st_ptrs3(st_BHCE_state, stream_BHCE_state,\
  51.     "BoundedHuffmanEncode state", bhce_enum_ptrs, bhce_reloc_ptrs,\
  52.     definition.counts, definition.values, encode.codes)
  53. extern const stream_template s_BHCE_template;
  54.  
  55. #define s_bhce_init_inline(ss)\
  56.   (s_hce_init_inline(ss), (ss)->zeros = 0)
  57.  
  58. /* BoundedHuffmanDecode */
  59. typedef struct stream_BHCD_state_s {
  60.     stream_BHC_state_common;
  61.     hcd_table decode;
  62. } stream_BHCD_state;
  63. #define private_st_BHCD_state()    /* in sbhc.c */\
  64.   gs_private_st_ptrs3(st_BHCD_state, stream_BHCD_state,\
  65.     "BoundedHuffmanDecode state", bhcd_enum_ptrs, bhcd_reloc_ptrs,\
  66.     definition.counts, definition.values, decode.codes)
  67. extern const stream_template s_BHCD_template;
  68.  
  69. #define s_bhcd_init_inline(ss)\
  70.   (s_hcd_init_inline(ss), (ss)->zeros = 0)
  71.  
  72. /* Declare variables that hold the decoder state. */
  73. #define bhcd_declare_state\
  74.     hcd_declare_state;\
  75.     int zeros
  76.  
  77. /* Load the state from the stream. */
  78. /* Free variables: pr, ss, p, rlimit, bits, bits_left, zeros. */
  79. #define bhcd_load_state()\
  80.     hcd_load_state(), zeros = ss->zeros
  81.  
  82. /* Store the state back in the stream. */
  83. /* Free variables: pr, ss, p, bits, bits_left, zeros. */
  84. #define bhcd_store_state()\
  85.     hcd_store_state(), ss->zeros = zeros
  86.